﻿using System;
using System.Collections.Generic;
using System.Text;

namespace csharpcore7_ch3.Chapt3_3ObjectClass
{
    public class Panda
    {
        public string Name;

        //重写ToString()方法
        public override string ToString() => Name;       
    }
    class Chapt3_3_4ToStringMethod
    {
        static void _Main()
        {
            int x = 1;
            string s = x.ToString(); // s is "1"
            Console.WriteLine(s);
            Panda p = new Panda { Name = "Petey"};
            Console.WriteLine(p.ToString());//如果不重写ToString方法，那么它会返回类型的名称
        }
    }
}
